package com.bwf.callable;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/19 13:52
 * @Copyright 博为峰
 */
public class ThreadDemo04 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //1.创建Callable接口实现类对象
        final MyThread04 myThread04 = new MyThread04();
        //2.创建FutureTask类对象
        final FutureTask<String> futureTask = new FutureTask<>(myThread04);
        //3.创建Thread类对象
        final Thread thread = new Thread(futureTask);
        //4.开启线程
        thread.start();
        //5.获取结果
        final String s = futureTask.get();
        System.out.println(s);
    }
}
